//多功能API-V1.2
//使用前请仔细查看以下参数
//From.TheHot.2019.3.9

//多开分身养号操作
function duokaiyh(多开分身,X,Y) {
    app.launchPackage("com.bly.dkplat");
    sleep(4000);
    var i = currentActivity();
    toastLog(i);
    switch (i) {
        case "com.bly.dkplat.widget.MainActivity":
            id("iv_btn_create").findOne().click();
            break;
        case "com.bly.dkplat.widget.manage.PluginConfigActivity":
            back();
            id("iv_btn_create").findOne().click();
            break;
        case "com.bly.dkplat.widget.create.SelectCreateAppActivity":
            break;
        default:
            break;
    }
    sleep(1000);
    click(X, Y);
    var c = className("android.widget.TextView").text(多开分身).findOne().bounds();
    var d = id("tv_btn").findOne().bounds();
    sleep(200);
    click(d.centerX(), c.centerY());
    sleep(200);
    id("tv_btn_advance").findOne().click();
    sleep(500);
    id("cb_virtual_sdcard").findOne().click();
    sleep(200);
    id("tv_btn_set_device").findOne().click();
    sleep(200);
    id("text1").findOne().parent().click();
    sleep(200);
    let xinghao = ["小米", "华为", "OPPO", "VIVO", "魅族", "索尼", "摩托罗拉", "三星", "努比亚", "谷歌", "一加", "金立", "美图", "酷派", "360"];
    let suiji = xinghao[random(0, 14)];
    className("android.widget.TextView").text(suiji).findOne().click();
    sleep(200);
    id("tv_apply").findOne().click();
    sleep(200);
    id("tv_create").findOne().click();
    sleep(200);
    waitForActivity("com.android.packageinstaller.PackageInstallerActivity");
    id("ok_button").findOne().click();
    id("launch_button").waitFor();
    id("launch_button").findOne().click();
}

//多开分身清数据
function duokai(多开分身) {
    sleep(1000);
    app.launchPackage("com.bly.dkplat");
    sleep(2000);
    back();
    sleep(200);
    u = currentActivity();
    if (u == "com.bly.dkplat.widget.manage.PluginConfigActivity") {
        sleep(20);
    } else {
        id("iv_btn_create").findOne(6000);
        let a = id("tv_btn_manage").text("管理").findOne().bounds()
        var tv_nameSize = id("tv_name").find().size();
        for (var i = 0; i < tv_nameSize; i++) {
            if (id("tv_name").find().get(i).text() == 多开分身) {
                break;
            }
        }
        let b = id("iv_logo").find().get(i).bounds();
        while (!click(a.centerX(), b.centerY()));
    }
    id("tv_btn_stop").findOne().click();
    sleep(200);
    id("tv_btn_clean").findOne().click();
    className("android.widget.TextView").text("完成").waitFor();
    sleep(200);
    back();
    id("tv_btn_set_device").findOne().click();
    id("tv_recover").findOne().click();
    back();
    id("tv_btn_set_device").findOne().click();
    id("text1").findOne().parent().click();
    let xinghao = ["小米", "华为", "OPPO", "VIVO", "魅族", "索尼", "摩托罗拉", "三星", "努比亚", "谷歌", "一加", "金立", "美图", "酷派", "360"];
    let suiji = xinghao[random(0, 14)];
    className("android.widget.TextView").text(suiji).findOne().click();
    sleep(200);
    id("tv_apply").findOne().click();
    toastLog("机型更换成功!");
    id("iv_logo").findOne().click(); //打开应用
}

//独享无极换IP
function wuji() {
    sleep(1000);
    launchApp("无极");
    sleep(200);
    id("exit_vpn").findOne().click();
    className("android.widget.Button").text("切换").waitFor();
    toastLog("切换IP成功!");
}

//共享版无极
function wujivpn() {
    sleep(1000);
    app.launchPackage("org.wuji");
    sleep(200);
    id("btn_startvpn").findOne().click();
    className("android.widget.Button").text("切换").waitFor();
    toastLog("切换IP成功!");
}

//光子换IP
function gz() {
    app.launchPackage("com.photon.hybrid");
    sleep(200);
    id("apv_switch").findOne().click();
    sleep(4000);
    toastLog("IP切换成功");
    sleep(200);
}

//PPTP换IP
function pptp() {
    var intent = new Intent("android.net.vpn.SETTINGS");
    app.startActivity(intent);
    sleep(200);
    var a = className("android.widget.CheckBox").findOne().bounds();
    if (className("android.widget.TextView").text("已连接").exists()) {
        click(a.centerX(), a.centerY());
    }
    sleep(500);
    click(a.centerX(), a.centerY());
    className("android.widget.TextView").text("已连接").waitFor();
}

//姓名随机函数
function getRandomName() {
    var firstNames = new Array("赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈",
        "褚", "卫", "蒋", "沈", "韩", "杨", "朱", "秦", "尤", "许", "何", "吕", "施", "张", "孔", "曹", "严", "华", "金", "魏",
        "陶", "姜", "戚", "谢", "邹", "喻", "柏", "水", "窦", "章", "云", "苏", "潘", "葛", "奚", "范", "彭", "郎", "鲁", "韦",
        "昌", "马", "苗", "凤", "花", "方", "俞", "任", "袁", "柳", "酆", "鲍", "史", "唐", "费", "廉", "岑", "薛", "雷", "贺",
        "倪", "汤", "滕", "殷", "罗", "毕", "郝", "邬", "安", "常", "乐", "于", "时", "傅", "皮", "卞", "齐", "康", "伍", "余",
        "元", "卜", "顾", "孟", "平", "黄", "和", "穆", "萧", "尹", "欧阳", "慕容"
    );
    var secondNames = new Array("子璇", "淼子", "国栋", "夫子", "瑞堂", "甜", "敏", "尚", "国贤", "贺祥", "晨涛", "昊轩", "易轩", "益辰", "益帆", "益冉", "瑾春", "瑾昆", "春齐", "杨", "文昊", "东东", "雄霖", "浩晨", "熙涵", "溶溶", "冰枫", "欣欣", "宜豪", "欣慧", "建政", "美欣", "淑慧", "文轩", "文杰", "欣源", "忠林", "榕润", "欣汝", "慧嘉", "新建", "建林", "亦菲", "林", "冰洁", "佳欣", "涵涵", "禹辰", "淳美", "泽惠", "伟洋", "涵越", "润丽", "翔", "淑华", "晶莹", "凌晶", "苒溪", "雨涵", "嘉怡", "佳毅", "子辰", "佳琪", "紫轩", "瑞辰", "昕蕊", "萌", "明远", "欣宜", "泽远", "欣怡", "佳怡", "佳惠", "晨茜", "晨璐", "运昊", "汝鑫", "淑君", "晶滢", "润莎", "榕汕", "佳钰", "佳玉", "晓庆", "一鸣", "语晨", "添池", "添昊", "雨泽", "雅晗", "雅涵", "清妍", "诗悦", "嘉乐", "晨涵", "天赫", "玥傲", "佳昊", "天昊", "萌萌", "若萌");
    var thirdNames = new Array("1", "2", "3", "4", "5", "6", "7", "8", "9");
    var firstLength = firstNames.length;
    var secondLength = secondNames.length;
    var thirdLength = thirdNames.length;
    var i = parseInt(Math.random() * firstLength);
    var j = parseInt(Math.random() * secondLength);
    var k = parseInt(Math.random() * thirdLength);
    var name = firstNames[i] + secondNames[j] + thirdNames[k] + thirdNames[random(0, 8)] + thirdNames[random(0, 8)];
    return name;
}

//取A-B之间的随机数
function randomNum(minNum, maxNum) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * minNum + 1, 10);
        case 2:
            return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
        default:
            return 0;
    }
}